package com.zhou.yygh.hosp.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.zhou.yygh.common.result.Result;

import com.zhou.yygh.hosp.service.DepartmentService;
import com.zhou.yygh.hosp.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import zhou.hospital.model.hosp.Hospital;
import zhou.hospital.vo.hosp.DepartmentVo;
import zhou.hospital.vo.hosp.HospitalQueryVo;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/hospital")

@Api(tags = "医院查询")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;
    @Autowired
    private DepartmentService departmentService;


    @GetMapping("/list/{page}/{limit}")
    public Result findPageHosp(@PathVariable Integer page,
                               @PathVariable Integer limit,
                               HospitalQueryVo hospitalQueryVo) {

        Page<Hospital> pageAll = hospitalService.selectHospPage(page, limit,hospitalQueryVo);
        return Result.ok(pageAll);

    }

    @ApiOperation(value = "更新医院状态")
    @GetMapping("/updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id,
                                   @PathVariable Integer status) {

        hospitalService.updateHospStatus(id, status);
        return Result.ok();
    }

    @ApiOperation(value = "医院详情信息")
    @GetMapping("/showHospDetail/{id}")
    public  Result showHospDetail(@PathVariable String id){
        Map<String, Object> hospital = hospitalService.getHospitalById(id);
        return Result.ok(hospital);

    }



}
